<?php
include('../include/setup.php');

include('menu.php');

//DELETE
if(isset($_GET['del']) && $_GET['del']==1 && isset($_GET['id']) ){
$db->Execute("delete from customer where id=".addslashes($_GET['id']));			
}		 

//LIST
$rs = $db->Execute('select id,firstname,lastname,age from customer');

$content = "";
$content.="
	<table border=\"1\">
	<tr><td colspan=\"5\"><div align=\"right\"><a href=\"add.php\">Tambah</a></div></td></tr>
	<tr>
	<td align=\"center\"><strong>ID</strong></td>
	<td align=\"center\"><strong>FIRSTNAME</strong></td>
	<td align=\"center\"><strong>LASTNAME</strong></td>
	<td align=\"center\"><strong>AGE</strong></td>
	<td align=\"center\"><strong>ACTION</strong></td>
	</tr>";
$data = $rs->GetRows();
for($i=0;$i<count($data);$i++){
	$content.="<tr>
		<td align=\"center\">".$data[$i]['id']."</td>
		<td>".$data[$i]['firstname']."</td>
		<td>".$data[$i]['lastname']."</td>
		<td align=\"center\">".$data[$i]['age']."</td>
		<td align=\"center\"><a href=\"edit.php?id=".$data[$i]['id']."\">Edit</a> <a href=\"listarray.php?id=".$data[$i]['id']."&del=1\">Del</a></td>
		</tr>";
}
$content.="</table>";

$smarty->assign("title","Array List Data");
$smarty->assign("content",$content);

//View
$smarty->display('index.tpl');
?>
